package com.taldh.algorithm.tianyiyun;

import java.util.Scanner;

public class CalYear {

    private static final int[] MONTH_DAY_ARRAY = new int[]{31,28,31,30,31,30,31,31,30,31,30,31};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {// 注意，如果输入是多个测试用例，请通过while循环处理多个测试用例
            int year = in.nextInt();
            int month = in.nextInt();
            int day = in.nextInt();
            System.out.println(getDaySequence(year, month, day)+" "+getWeekday(year, month, day));
        }
    }

    private static boolean isLeapYear(int year) {
        return (year % 100 != 0 && year % 4 == 0) || (year % 400 == 0);
    }

    private static int getDaySequence(int year, int month, int day) {
        int daySequence = 0;
        for (int i = 0; i < month - 1; i++) {
            daySequence += MONTH_DAY_ARRAY[i];
        }
        if (month > 2 && isLeapYear(year)) {
            daySequence ++;
        }
        return daySequence + day;
    }

    private static int getWeekday(int year, int month, int day) {
        return  (day + 2*month + 3*(month+1)/5 + year + year/4 - year/100 + year/400  + 1) % 7;
    }

}
